<template>
  <div class="page-article w-100">
    <div class="d-flex border-bottom py-3 ai-center">
      <div class="iconfont icon-back text-blue"></div>
      <strong class="flex-1 text-ellipsis text-blue pl-1">
        {{model.title}}
      </strong>
      <div class="text-gray fs-xs">
        2019-06-19
      </div>
    </div>
    <div v-html="model.description" class="px-3 body text-center "></div>
    <div class="px-3 border-top py-2">
      <div class="d-flex ai-center">
        <i class="iconfont icon-menu"></i>
        <span class="text-blue fs-lg ml-1">相关资讯</span>
      </div>
      <div class="pt-2 fs-lg">
        <router-link class="py-2 text-ellipsis" tag="div" :to="`/articles/${item._id}`"
          v-for="(item,i) of model.related" :key="i">
          {{item.title}}
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    id: { required: true }
  },
  data () {
    return {
      model: {}
    }
  },
  watch: {
    id: 'fetch'
    // id() {
    //   this.fetch()
    // }
  },
  methods: {
    async fetch () {
      const res = await this.$http.get(`articles/${this.id}`)
      this.model = res.data
      console.log(this.model)
    }
  },
  created () {
    this.fetch()
  }
}
</script>

<style lang="scss">
.page-article {
  overflow: hidden;
}
.icon-back {
  font-size: 12px !important;
}
.page-article {
  .body {
    img {
      width: 100%;
      height: auto;
    }
  }
}
</style>
